package com.prs.crm.domain.sale;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.Invoice;

/**
 * 销售发票
 * @author prs.chenzhi
 *
 */
@Entity
@DiscriminatorValue(value = "1")
public class SaleInvoice extends Invoice{
	
	private static final long serialVersionUID = 1L;
	

	@OneToMany(mappedBy = "invoice")
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<SaleInvoiceItem> items;
	
	
	
	//关联发货单
	@ManyToOne
	private SalesStoreOut storeOutBill;


	public void setItems(Set<SaleInvoiceItem> items) {
		this.items = items;
	}

	
	public Set<SaleInvoiceItem> getItems() {
		return items;
	}
	
	public void addItem(SaleInvoiceItem item)
	{
		if (items==null)
			items = new HashSet<SaleInvoiceItem>();
		items.add(item);
	}


	public void setStoreOutBill(SalesStoreOut storeOutBill) {
		this.storeOutBill = storeOutBill;
	}


	public SalesStoreOut getStoreOutBill() {
		return storeOutBill;
	}

}
